package speechprocess;

/**
 *
 * @author KieuOanh
 */
public class Magnitude {

    double SAMPLE_RATE = 10000;
    double T = 1 / SAMPLE_RATE;
    double F = SAMPLE_RATE / 2;
    double theta;
    double z;
    double delta;
    double d;
    double cosTheta;
    double sinTheta;
    double cosw;
    double sinw;
    double cos2w;
    double sin2w;
    double c;
    double a;
    double p;
    double q;
    Complex hF;
    double HF;
    double tan;
    double argtg;

    public Magnitude(double fK, double bandw, int f) {
        theta = 2 * Math.PI * fK * T;
        delta = bandw / 2;
        z = Math.exp((-delta) * T);
        d = z * z;
        cosTheta = Math.cos(theta);
        sinTheta = Math.sin(theta);
        c = 1 - 2 * z * cosTheta + d;
        a = -2 * z * cosTheta;

        cosw = Math.cos(2 * Math.PI * f * T);
        sinw = Math.sin(2 * Math.PI * f * T);

        cos2w = Math.cos(2 * 2 * Math.PI * f * T);
        sin2w = Math.sin(2 * 2 * Math.PI * f * T);

        p = 1 + a * cosw + d * cos2w;
        q = a * sinw + d * sin2w;

        hF = new Complex(c * p / (p * p + q * q), -c * q / (p * p + q * q));

        tan = -q / p;
        argtg = Math.atan(tan);
    }
}